package anbook.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Database {
	public static Connection Open() throws ClassNotFoundException, SQLException{
		Class.forName("com.mysql.jdbc.Driver");
		String jdbcDriver = "jdbc:mysql://localhost:3306/anbook?useUnicode=true&characterEncoding=utf8";
		String dbUser = "anid";
		String dbPwd = "anpass";
		
		return DriverManager.getConnection(jdbcDriver, dbUser, dbPwd);
	}
	
	public static void Close(Connection con,PreparedStatement pstmt, ResultSet rs){
		if (rs != null) try{rs.close();} catch(SQLException se){}
		if (pstmt != null) try{pstmt.close();} catch(SQLException se){}
		if (con != null) try{con.close();} catch(SQLException se){}
	}
}
